import * as request from '@/services/api';

// 请求成功
// const SUCCESS = '1';

export default {
  namespace: 'global',
  state: {
    userId: sessionStorage.getItem("userId") ||"luhual"
  },
  effects: {

    //获取收藏列表
    * getCollectionList({ payload }, { call, put }) {
      const res = yield call(request.getCollectionList, payload);
      return res;
    },
    //获取收藏列表
    * getUserInfo({ payload }, { call, put }) {
      const res = yield call(request.getUserInfo, payload);
      return res;
    },
    //删除收藏
    * deleteCollection({ payload }, { call }) {
      const res = yield call(request.deleteCollection, payload);
      return res;
    },
    //获取分享给人列表
    * getShareList({ payload }, { call }) {
      const res = yield call(request.getShareList, payload);
      return res;
    },
    //分享删除
    * deleteShare({ payload }, { call }) {
      const res = yield call(request.deleteShare, payload);
      return res;
    },
    //获取科研数据图片
    * getFirst({ payload }, { call }) {
    const res = yield call(request.getFirst, payload);
    return res;
    },
    //获取科研数据图片
    * getDataAsset({ payload }, { call }) {
    const res = yield call(request.getDataAsset, payload);
    return res;
    },
    //获取科研数据详情页图片
    * getDataAssetid({ payload }, { call }) {
    const res = yield call(request.getDataAssetid, payload);
    return res;
    },
    //------------------------标准-----------------------
    // 获取标准列表
    * getStandardList({ payload }, { call }) {
      const res = yield call(request.getStandardList, payload);
      return res;
    },
    //标准描述增加/编辑
    * createStandard({ payload }, { call }) {
      const res = yield call(request.createStandard, payload);
      return res;
    },
    //标准描述删除
    * deleteStandard({ payload }, { call }) {
      const res = yield call(request.deleteStandard, payload);
      return res;
    },
    //标准详情
    * getStandardInfo({ payload }, { call }) {
      const res = yield call(request.getStandardInfo, payload);
      return res;
    },
    //标准状态
    * getByTypedic({ payload }, { call }) {
      const res = yield call(request.getByTypedic, payload);
      return res;
    },
    //标准元数据列表
    * getBasicFieldInfoList({ payload }, { call }) {
      const res = yield call(request.getBasicFieldInfoList, payload);
      return res;
    },
    //详细标准列表
    * getStandDetailInfoList({ payload }, { call }) {
      const res = yield call(request.getStandDetailInfoList, payload);
      return res;
    },
    //标准元数据新增/编辑
    * saveBasicFieldInfo({ payload }, { call }) {
      const res = yield call(request.saveBasicFieldInfo, payload);
      return res;
    },
    //标准元数据选择项新增
    * saveBasicFieldOptionInfo({ payload }, { call }) {
      const res = yield call(request.saveBasicFieldOptionInfo, payload);
      return res;
    },
    //标准元数据选择项数据
    * getBasicFieldOptionInfoById({ payload }, { call }) {
      const res = yield call(request.getBasicFieldOptionInfoById, payload);
      return res;
    },
    //标准元数据选择项删除
    * deleteBasicFieldOptionInfo({ payload }, { call }) {
      const res = yield call(request.deleteBasicFieldOptionInfo, payload);
      return res;
    },
    //标准元数据删除
    * deleteBasicFieldInfo({ payload }, { call }) {
      const res = yield call(request.deleteBasicFieldInfo, payload);
      return res;
    },
    //详细标准增加
    * saveStandDetailInfo({ payload }, { call }) {
      const res = yield call(request.saveStandDetailInfo, payload);
      return res;
    },
    //详细标准删除
    * deleteStandDetailInfo({ payload }, { call }) {
      const res = yield call(request.deleteStandDetailInfo, payload);
      return res;
    },
    //详细标准详情
    * getStandDetailInfo({ payload }, { call }) {
      const res = yield call(request.getStandDetailInfo, payload);
      return res;
    },
    //详细标准导出
    * downloadStandModel({ payload }, { call }) {
      const res = yield call(request.downloadStandModel, payload);
      return res;
    },
    //详细标准导入
    * importExcel({ payload }, { call }) {
      const res = yield call(request.importExcel, payload);
      return res;
    },

    //----------------------科研软件-----------------------
    //科研软件分类树
    * getDirs({ payload }, { call }) {
      const res = yield call(request.getDirs, payload);
      return res;
    },
    //科研软件分类增加编辑
    * saveDir({ payload }, { call }) {
      const res = yield call(request.saveDir, payload);
      return res;
    },
    //科研软件分类删除
    * deleteDir({ payload }, { call }) {
      const res = yield call(request.deleteDir, payload);
      return res;
    },
    //科研软件列表
    * getKnowledgeByPage({ payload }, { call }) {
      const res = yield call(request.getKnowledgeByPage, payload);
      return res;
    },
    //科研软件新增
    * saveKnowledge({ payload }, { call }) {
      const res = yield call(request.saveKnowledge, payload);
      return res;
    },
    //科研软件删除
    * deleteKnowledge({ payload }, { call }) {
      const res = yield call(request.deleteKnowledge, payload);
      return res;
    },
    //科研软件详情
    * getKnowledgeInfo({ payload }, { call }) {
      const res = yield call(request.getKnowledgeInfo, payload);
      return res;
    },
    //----------------专题------------------
    //专题列表
    * getTopicByPage({ payload }, { call }) {
      const res = yield call(request.getTopicByPage, payload);
      return res;
    },
    //专题新增/编辑
    * saveTopic({ payload }, { call }) {
      const res = yield call(request.saveTopic, payload);
      return res;
    },
    //专题删除
    * deleteTopic({ payload }, { call }) {
      const res = yield call(request.deleteTopic, payload);
      return res;
    },
    //专题详情
    * getTopicInfo({ payload }, { call }) {
      const res = yield call(request.getTopicInfo, payload);
      return res;
    },
    //专题筛选
    * getKnowledgeListInfos({ payload }, { call }) {
      const res = yield call(request.getKnowledgeListInfos, payload);
      return res;
    },
    //专题筛选
    * getDataAssetListInfos({ payload }, { call }) {
      const res = yield call(request.getDataAssetListInfos, payload);
      return res;
    },
    //----------------------帮助-----------------------
    //帮助新增/编辑
    * helpSave({ payload }, { call }) {
      const res = yield call(request.helpSave, payload);
      return res;
    },
    //帮助删除
    * helpDelete({ payload }, { call }) {
      const res = yield call(request.helpDelete, payload);
      return res;
    },
    //通过id获取帮助文档内容
    * getHelpInfo({ payload }, { call }) {
      const res = yield call(request.getHelpInfo, payload);
      return res;
    },
    //获取帮助文档分页
    * getHelpByPage({ payload }, { call }) {
      const res = yield call(request.getHelpByPage, payload);
      return res;
    },
    //获取目录
    * getHelp({ payload }, { call }) {
      const res = yield call(request.getHelp, payload);
      return res;
    },


    //----------------------意见-----------------------
    //意见分页查询
    * selectByPage({ payload }, { call }) {
      const res = yield call(request.selectByPage, payload);
      return res;
    },
    //意见详情
    * selectById({ payload }, { call }) {
      const res = yield call(request.selectById, payload);
      return res;
    },
    //意见处理
    * handle({ payload }, { call }) {
      const res = yield call(request.handle, payload);
      return res;
    },

    //文件上传
    * upload({ payload }, { call }) {
      const res = yield call(request.upload, payload);
      return res;
    },
    //字典获取
    * getByType({ payload }, { call }) {
      const res = yield call(request.getByType, payload);
      return res;
    },
    //字典获取
    * queryCategory({ payload }, { call }) {
      const res = yield call(request.queryCategory, payload);
      return res;
    },

  },
  reducers: {
    saveVehicleDBList(state, active) {
      return {
        ...state,
        vehicleDBList: active.payload
      };
    },
  }
};
